<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>destructuring</title>
</head>
<body>
<script>
    // 1、交换变量的值
    //     es5
    console.log('es5');
    var a=100;
    var b=200;
    console.log('交换前：');
    console.log('a='+a);
    console.log('a='+b);
    var temp=a;
    temp=a;
    a=b;
    b=temp;
    console.log('交换后：');
    console.log('a='+a);
    console.log('a='+b);

    console.log('es6');
    var x=100;
    var y=200;
    console.log('交换前：');
    console.log('x='+x);
    console.log('y='+y);
    [x,y]=[y,x];
    console.log('交换后：');
    console.log('x='+x);
    console.log('y='+y);
</script>
</body>
</html>